package com.lin.controller;


import com.lin.base.Result;
import com.lin.entity.Department;
import com.lin.entity.WarningDevice;
import com.lin.service.impl.DepartmentServiceImpl;
import com.lin.service.impl.WarningDeviceServiceImpl;
import com.lin.service.impl.WarningLogServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lin
 * @since 2022-06-17
 */
@RestController
@RequestMapping("/api/warning_device")
public class WarningDeviceController {

    @Resource
    WarningDeviceServiceImpl warningDeviceService;

    @GetMapping("/list")
    public Result getWarningDevice(@RequestParam Integer page,
                                   @RequestParam Integer size,
                                   @RequestParam Integer departmentDid,
                                   @RequestParam(required = false) String key) {
        return Result.ok(warningDeviceService.getWarningDevice(page,size,departmentDid,key));
    }

    @PostMapping("/add")
    public Result addWarningDevice(@RequestBody WarningDevice warningDevice) {
        return Result.ok(warningDeviceService.addWarningDevice(warningDevice));
    }

    @PostMapping("/update")
    public Result updateWarningDevice(@RequestBody WarningDevice warningDevice) {
        warningDeviceService.updateWarningDevice(warningDevice);
        return Result.ok("修改成功");
    }

    @PostMapping("/remove")
    public Result removeWarningDevice(@RequestParam Integer id) {
        warningDeviceService.removeWarningDevice(id);
        return Result.ok("删除成功");
    }
}
